package com.shuoyue.ycgk.ui.main.adv;

import androidx.viewpager.widget.ViewPager;

import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.BaseMvpActivity;
import com.shuoyue.ycgk.base.BaseMvpFragment;
import com.shuoyue.ycgk.base.baseadapter.IndexFragmentAdapter;
import com.shuoyue.ycgk.views.PageIndicator;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class LauncherAdvActivity extends BaseMvpActivity {
    @BindView(R.id.indicator)
    PageIndicator indicator;
    @BindView(R.id.pager)
    ViewPager pager;

    List<BaseMvpFragment> fragmentList = new ArrayList<>();
    IndexFragmentAdapter fragmentAdapter;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_launcher_adv;
    }

    @Override
    protected void initView() {
    }


    @Override
    public void initData() {
        setConfigMedias();
    }

    public void setConfigMedias() {
        fragmentList.add(FragmentAdv.getInstance(R.mipmap.adv_1));
        fragmentList.add(FragmentAdv.getInstance(R.mipmap.adv_2));

        fragmentList.add(FragmentAdvLast.getInstance());
        fragmentAdapter = new IndexFragmentAdapter(getSupportFragmentManager(), fragmentList);
        pager.setAdapter(fragmentAdapter);
        indicator.setNumPages(3);
        indicator.setCurrentPage(0);
        pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                if (indicator != null)
                    indicator.setCurrentPage(position);
            }
        });

    }


}